import { BasicColumn, FormSchema } from '/@/components/Table';
import { getAccountList, getAllRoleList, setRoleStatus } from '/@/api/demo/system';

export const columns: BasicColumn[] = [
    {
        title: '工单',
        dataIndex: 'name',
        width: 100,
    },
    {
        title: '创建人',
        dataIndex: 'createUserName',
        width: 50,
        customRender: ({ record }) => {
            return record.realName ? record.realName : record.createUserName;
        },
    },
    {
        title: '工单状态',
        dataIndex: 'status',
        width: 50,
    },
    {
        title: '创建时间',
        dataIndex: 'CreatedAt',
        width: 70,
    },
];


// 工单状态对象
export const workOrderInstanceStatus: object = {
    WorkOrderInstanceStatusPendingApproval: 'pendingApproval',
    WorkOrderInstanceStatusPendingAction: 'pendingAction',
};



// 搜索表单配置
export const workOrderInstanceSearchFormSchema: FormSchema[] = [
    {
        field: 'queryMode',
        label: '查询模式',
        component: 'Select',
        defaultValue: '',
        componentProps: {
            options: [
                { label: '我创建的', value: 'mine' },
                { label: '待我审批的', value: 'Approval' },
                { label: '待我执行的', value: 'Action' },
                { label: '全部的', value: 'all' },
            ],
        },
        colProps: { span: 12 },
    },
    {
        field: 'name',
        label: '工单名称',
        component: 'Input',
        colProps: { span: 12 },
    },
    {
        field: 'status',
        label: '工单状态',
        component: 'Select',
        defaultValue: '',
        componentProps: {
            options: [
                { label: '待审批的', value: 'pendingApproval' },
                { label: '审批拒绝的', value: 'approvalReject' },
                { label: '待执行的', value: 'pendingAction' },
                { label: '已执行完成的', value: 'finished' },
            ],
        },
        colProps: { span: 12 },
    },
    {
        label: '创建人',
        field: 'UserID',
        component: 'ApiSelect',
        componentProps: {
            api: getAccountList,
            resultField: 'items',
            labelField: 'realName', // 显示真实姓名
            valueField: 'id',
        },
        colProps: { span: 12 },
    },
];




// 表单配置
export const formSchema: FormSchema[] = [
    {
        field: 'name',
        label: '工单名称',
        required: true,
        component: 'Input',
        colProps: { span: 12 },
    },
    {
        field: 'desireFinishTime',
        component: 'DatePicker',
        label: '期望完成时间',
        colProps: { span: 15 },
    },
];



// 工单操作表单配置
export const formSchemaOrderAction: FormSchema[] = [
    {
        field: 'isSuccess',
        label: '是否成功',
        defaultValue: true,
        component: 'RadioButtonGroup',
        componentProps: {
            options: [
                { label: '成功', value: true },
                { label: '失败', value: false },
            ],
        },
        colProps: { span: 24 },
    },
    {
        field: 'output',
        label: '结果输出',
        required: true,
        component: 'InputTextArea',
        colProps: { span: 24 },
    },
];

